import instance from "../utils/request";

export async function createTransportationPlan(transportationPlan){
    try {
        const res = await instance({
            url: '/TransportationPlan/create',
            method: 'post',
            data: transportationPlan
        });
        return res;
    } catch (err) {
        console.log(err);
    }
}

export async function updateTransportationPlan(transportId, transportationPlan){
    try {
        const res = await instance({
            url: '/TransportationPlan/update',
            method: 'put',
            params: {
                transportId: transportId
            },
            data: transportationPlan
        });
        return res;
    } catch (err) {
        console.log(err);
    }
}

export async function deleteTransportationPlan(transportId){
    try {
        const res = await instance({
            url: `/TransportationPlan/delete/${transportId}`,
            method: 'delete',
        });
        return res;
    } catch (err) {
        console.log(err);
    }
}

export async function deleteTransportationPlanByPlanId(planId){
    try {
        const res = await instance({
            url: `/TransportationPlan/delete/plan/${planId}`,
            method: 'delete',
        });
        return res;
    } catch (err) {
        console.log(err);
    }
}

export async function getTransportationPlan(transportId){
    try {
        const res = await instance({
            url: `/TransportationPlan/detail/${transportId}`,
            method: 'get',
        });
        return res;
    } catch (err) {
        console.log(err);
    }
}

export async function getTransportationPlansByPlanId(planId, pageNumber, pageSize){
    try {
        const res = await instance({
            url: `/TransportationPlan/plans/${planId}`,
            method: 'get',
            params: {
                pageNumber: pageNumber,
                pageSize: pageSize
            }
        });
        return res;
    } catch (err) {
        console.log(err);
    }
}